import { defineComponent, reactive, ref, computed } from "vue";
import styles from "./searchQRcode.module.less";
import LPopup from "@/components/public/lPopup/lPopup";
import {$generateQRcode} from "@/api/channel/channel";
export default defineComponent({
  setup(props, { emit, expose }) {
    const state = reactive({
         url:"",
    } as any);
    const cancelHandler = () => {
      addPopupRef.value.close();
    };

    const addPopupRef = ref(null as any);
    const open = (e:any) => {
      console.log("jin",e);
      $generateQRcode(e).then((res:any)=>{
         console.log(e);
          state.url = res?.data?.qrcode_url || "";
      })
      addPopupRef.value.open();
    };
    const close = () => {
      addPopupRef.value.close();
    };
    expose({
      open,
      close,
    });
    const Components = () => (
      <LPopup title="二级渠道二维码" ref={addPopupRef}>
          <div class={styles.qrcode}>
               <a-image  width="200" src={state.url}/>
          </div>
      </LPopup>
    );
    return {
      Components,
    };
  },
  render() {
    return <this.Components />;
  },
});
